<template>
  <el-dialog
    title="编辑商品"
    :visible.sync="dialogvisible"
    width="40%"
    :before-close="shutdown"
  >
    <el-form ref="form" :model="onegooddata" label-width="80px" size="mini">
      <el-form-item label="编号">
        <el-input v-model="onegooddata.number" />
      </el-form-item>
      <el-form-item label="所属店">
        <el-input v-model="onegooddata.Belong" />
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="onegooddata.name" />
      </el-form-item>
      <el-form-item label="商品分类">
        <el-select v-model="onegooddata.pid" placeholder="请选择活动区域">
          <el-option v-for="v in parentsdata" :key="v.id" :label="v.name" :value="v.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="类型">
        <el-input v-model="onegooddata.type" />
      </el-form-item>
      <el-form-item label="成本价">
        <el-input v-model="onegooddata.costprice" />
      </el-form-item>
      <el-form-item label="原价">
        <el-input v-model="onegooddata.originalprice" />
      </el-form-item>
      <el-form-item label="售价">
        <el-input v-model="onegooddata.sellingprice" />
      </el-form-item>
      <el-form-item label="库存量">
        <el-input v-model="onegooddata.inventory" />
      </el-form-item>
      <el-form-item label="月销售量">
        <el-input v-model="onegooddata.monthlysales" />
      </el-form-item>
      <el-form-item label="总销售量">
        <el-input v-model="onegooddata.totalsales" />
      </el-form-item>
      <el-form-item label="月销售额">
        <el-input v-model="onegooddata.monthlymoney" />
      </el-form-item>
      <el-form-item label="总销售额">
        <el-input v-model="onegooddata.totalmoney" />
      </el-form-item>
      <el-form-item label="参与活动">
        <el-input v-model="onegooddata.activities" />
      </el-form-item>
      <el-form-item label="临保时长">
        <el-input v-model="onegooddata.keeptime" />
      </el-form-item>
      <el-form-item label="账号限购">
        <el-input v-model="onegooddata.monthlysales" />
      </el-form-item>
      <el-form-item label="秒杀价">
        <el-input v-model="onegooddata.originalprice" />
      </el-form-item>
      <el-form-item label="促销价">
        <el-input v-model="onegooddata.originalprice" />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="shutdown">取 消</el-button>
      <el-button type="primary" @click="editdata">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { editdata } from '@/api/commodity.js';
export default {
  props: {
    dialogvisible: {
      type: Boolean,
    },
    onegooddata: {
      type: Object,
      default: function de() {},
    },
    parentsdata: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {};
  },
  methods: {
    editdata() {
      editdata(this.onegooddata, this.onegooddata.id).then(() => {
        this.$message.success('修改成功');
        this.$emit('editdata');
      }, () => {
        this.$message.error('修改失败');
      });
    },
    shutdown() {
      this.$emit('shutdown');
    },
  },
};
</script>
